#include <iostream>
using namespace std;

class Base {
public:
    virtual void f(int a) { cout << "base : f : " << a << endl;}
    virtual void g(int a) { cout << "base : g : " << a << endl;}
    virtual void h(int a) { cout << "base : h : " << a << endl;}
};

typedef void(*Fun)(int);

int main() {
typedef void(*CFun)(Base *, int a);
    Base b;
    Base b2;
    Fun pFun = NULL;
    cout << "v-table point : " << (int*)(&b) << endl;
    cout << "v-table point : " << (int*)(&b2) << endl;
    cout << "v-table - the first function address : "
         << (int*)*(int*)(&b) << endl;
    cout << "v-table - the first function address : "
         << (int*)*(int*)(&b2) << endl;

    if ( (int*)(&b) == (int*)(&b2)) {
        cout << "== " << endl;
    } else {
        cout << "!=" << endl;
    }
    pFun = (Fun)*((int*)*(int*)(&b));
    pFun(5);
    ((Fun)*(((int*)*(int*)(&b))+1))(8);
    ((Fun)*(((int*)*(int*)(&b))+2))(9);
    int * vobj = (int *)&b2;
    int * vb = (int *)*vobj;
    CFun c = (CFun)*vb;
    c(&b2, 4);
    //((CFun)*(((int*)*(int*)(&b2))+1))(&b2, 4);

    int * p1 = (int*)(&b);
    int * p2 = (int*)(&b2);
    cout << p1 << "--" << p2 << endl;
    int * pt1 = (int *)* p1;
    int * pt2 = (int *)* p2;
    cout << pt1 << "--" << pt2 << endl;
    int ** ppt1 = (int **)(&b);
    int ** ppt2 = (int **)(&b2);
    cout << ppt1 << "--" << ppt2 << endl;
    cout << *ppt1 << "--" << *ppt2 << endl;
}


